import { defineStore } from "pinia";
import { ref } from "vue";
const useStore = defineStore(
	"szgb",
	() => {
		const activeMenu = ref("");
		const openedMenu = ref([]);
		const user = ref({});
		const dict = ref({});
		const cxhtForm = ref({});
		const setActiveMenu = (data) => {
			activeMenu.value = data;
		};
		const setOpenedMenu = (data) => {
			openedMenu.value = data;
		};
		const setUser = (data) => {
			user.value = data;
		};
		const setDict = (data) => {
			dict.value = data;
		};
		const setCxhtForm = (data) => {
			cxhtForm.value = data;
		};

		const clearAll = () => {
			activeMenu.value = "";
			openedMenu.value = [];
			user.value = {};
			dict.value = {};
			cxhtForm.value = {};
		};
		return {
			activeMenu,
			setActiveMenu,
			openedMenu,
			setOpenedMenu,
			user,
			setUser,
			dict,
			setDict,
			cxhtForm,
			setCxhtForm,
			clearAll,
		};
	},
	{
		persist: {
			enabled: true,
		},
	}
);
export default useStore;
